package com.cy;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;


@RefreshScope
@RestController
@RequestMapping("/provider")
public class RestProviderController {
    @Value("${page.pageSize:10}")
    private Integer pageSize;
    @Value("${logging.level.com.cy:error}")
    private String logger;
    @Value("${server.tomcat.threads.max:200}")
    private String maxThread;
    @GetMapping("/doGetPageSize")
    public String doGetPageSize(){
        return "pageSize is "+pageSize;
    }
    @GetMapping("/doGetMaxThread")
    public String doGetMaxThread(){
        return "tomcat max thread is "+maxThread;
    }
    @GetMapping("/doGetLogLevel")
    public String doGetLogLevel(){
        return "log level is "+logger;
    }
    @DeleteMapping("/{id}")
    public String doDeleteById(@PathVariable Long ...id){
        return Arrays.toString(id)+"is deleted";
    }
    @PostMapping
    public String doCreate(@RequestBody Map<String,Object> map){
        System.out.println("provider.map=" + map);
        return "create ok";
    }
    @PutMapping
    public Map doUpdate(@RequestBody Map<String,Object> map){
        System.out.println("provider.map=" + map);
        Map map1=new HashMap();
        map1.put("status",200);
        map1.put("message","update ok");
        return map1;
    }
}
